package cn.tedu.management.portal.controller;


import cn.tedu.management.portal.dto.PostAddRoleDTO;
import cn.tedu.management.portal.service.IRoleService;
import cn.tedu.management.portal.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author tedu.cn
 * @since 2020-12-08
 */
@RestController
@RequestMapping("/portal/role")
public class RoleController {
    @Autowired
    IRoleService roleService;

    //http://localhost:8080/portal/role/register?name=Jack
    @PostMapping("/register")
    public R<Void> registerRole(PostAddRoleDTO postAddRoleDTO){
        roleService.registerUser(postAddRoleDTO);
        return R.ok();
    }

    //http://localhost:8080/portal/role/delete?id=5
    @PostMapping("/delete")
    public R<Void> deleteById(Integer id){
        roleService.deleteById(id);
        return R.ok();
    }
}
